<template>
	<view class="order">
		<view class="tabBox">
			<u-scroll-list style="width: 100% !important;" :indicator="false">
				<view class="" style="display: flex;">
					<view class="navItem" v-for="(i,index) in typeList" :key="index"
						:style="{color:(tabCurrent == i.id?'#F06E56':'#979797')}" @tap.stop="tabChange(i.id)">
						<view class="">
							{{i.name||''}}
						</view>
						<view class="line" :style="{backgroundColor:(tabCurrent == i.id?'#F06E56':'#fff')}"></view>
					</view>
				</view>
			</u-scroll-list>
		</view>
		<!-- 列表 -->
		<view class="listBox" v-if="tabCurrent == 2">
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="order_tit">
					<view class="num">
						编号:{{item.order_no||''}}
					</view>
					<view class="count"
						:style="{color:(item.status==0?'#2CB9A4':(item.status==1?'#FC8E23':'#979797'))}">
						{{item.status==0?'待结算':(item.status==1?'已结算':'已退款')}}
					</view>
				</view>
				<view class="list_l" v-for="(i,index) in item.goods" :key="index">
					<image v-if="i.image" :src="baseUrl+i.image" mode=""></image>
					<view class="list_l_r">
						<view class="name" style="font-size: 26rpx;">{{i.title||''}}</view>
						<view class="name">
							<view class="" style="color: #F06E56;">
								￥{{i.price||0}}
							</view>
							<view class="num">
								x{{i.number||0}}
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<view class="memberBox" v-if="tabCurrent == 1">
			<view class="list" v-for="(item,index) in list" :key="index">
				<view class="list_t">
					<view class="name">VIP·{{item.level.name||''}}</view>
					<view class="time">
						{{item.createtime_text||''}}
					</view>
				</view>
				<view class="list_b">
					<view class="time">￥{{item.level.price||0}}</view>
					<view class="time">
						<image v-if="item.payuser.avatar" :src="item.payuser.avatar" mode=""></image>
						<view class="">
							{{item.payuser.nickname||''}}
						</view>
					</view>
					<!-- <view class="btn">补贴￥{{item.phone}}</view> -->
				</view>
			</view>

		</view>

		<!-- 提示栏 -->
		<view class="more">{{isText}}</view>

	</view>
	</view>
</template>

<script>
	import config from '@/common/config/config';
	export default {
		data() {
			return {
				typeList: [{
					id: 1,
					name: '会员类订单'
				}, {
					id: 2,
					name: '购物类订单'
				}],
				baseUrl: config.baseurl,
				tabCurrent: 1,
				page: 1,
				list: [],
				isText: '',
				last_page: 1,
			};
		},
		onLoad() {

		},
		onShow() {
			this.init()
			this.getList()
		},
		methods: {
			init() {
				this.list = []
				this.page = 1
				this.isText = ''
			},
			// tab 切换
			tabChange(e) {
				this.init()
				this.tabCurrent = e
				this.getList()
			},
			// 获取员工列表
			getList() {
				let that = this

				uni.request({
					url: '/wanlshop/distribution/orderList',
					data: {
						page: that.page,
						type: that.tabCurrent
					},
					success: res => {
						that.list = that.list.concat(res.data.data)
						that.last_page = res.data.last_page
						res.data.total == that.list.length ? that.isText = '暂无数据' : that.isText = ''
						console.log(that.list, 'that.list')
					}
				});
			},
			// 跳转到详情页面
			goDetails(el) {
				let res = {
					order_number: el.order_number,
					goods_img: el.goods_img,
					goods_name: el.goods_name
				}
				uni.navigateTo({
					url: '/pages/order/details/details?res=' + JSON.stringify(res)
				})
			}
		},
		onReachBottom() {
			let that = this
			if (that.page < that.last_page) {
				that.page = that.page + 1
				that.getList()
			}
		}

	}
</script>

<style lang="less">
	page {
		background-color: #f9f9f9;
	}

	.u-tab-bar {
		display: none !important;
	}

	.more {
		width: 100%;
		text-align: center;
		font-size: 28rpx;
		margin: 30rpx auto;
		padding-bottom: 50rpx;
	}

	.order {
		width: 100vw;

		.memberBox {
			width: 95%;
			margin: 30rpx auto;

			.list {
				width: 100%;
				height: auto;
				padding: 20rpx;
				border-radius: 20rpx;
				background-color: #fff;
				margin: 20rpx auto;

				.list_t {
					width: 100%;
					display: flex;
					font-size: 28rpx;
					font-weight: 400;
					justify-content: space-between;
					align-items: center;
					padding-bottom: 10rpx;
					border-bottom: 2rpx solid #eae9e9;

					.name {
						height: 50rpx;
						line-height: 50rpx;
					}

					.time {
						font-size: 26rpx;
						color: #BABABA;
					}
				}

				.list_b {
					width: 100%;
					font-size: 26rpx;
					display: flex;
					margin-top: 16rpx;
					justify-content: space-between;

					.time {
						color: #F06E56;
						margin-right: 16rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;

						image {
							width: 60rpx;
							height: 60rpx;
							border-radius: 50%;
							margin-right: 10rpx;
						}
					}

					.btn {
						color: #BABABA;
						text-decoration: line-through;
					}

				}
			}
		}

		.tabBox {
			display: flex;
			justify-content: space-between;
			width: 100%;
			padding: 22rpx;
			box-sizing: border-box;
			padding-bottom: 0;
			text-align: left;
			font-size: 28rpx;
			overflow-x: auto;
			background-color: #fff;

			/deep/.u-scroll-list {
				padding-bottom: 0 !important;
			}

			.navItem {
				padding: 0 80rpx 0rpx 10rpx;
				text-align: center !important;

				.line {
					width: 100%;
					height: 2rpx;
					margin-top: 16rpx;
				}
			}
		}

		.listBox {
			width: 95%;
			margin: 30rpx auto;
			margin-top: 10rpx;

			.list {
				width: 100%;
				height: auto;
				padding: 20rpx;
				border-radius: 20rpx;
				background-color: #fff;
				margin: 20rpx auto;

				.order_tit {
					height: 58rpx;
					line-height: 45rpx;
					color: #000;
					border-bottom: 2rpx solid gainsboro;
					font-size: 30rpx;
					display: flex;
					justify-content: space-between;

					.count {
						font-size: 28rpx;
					}
				}

				.list_l {
					margin: 14rpx auto;
					width: 100%;
					color: #252525;
					display: flex;
					align-items: center;

					image {
						width: 84rpx;
						height: 84rpx;
					}

					.list_l_r {
						font-size: 28rpx;
						font-weight: 400;
						margin-left: 20rpx;
						width: 86%;

						.name {
							height: 50rpx;
							line-height: 50rpx;
							display: flex;
							color: #000;
							justify-content: space-between;
							align-items: center;

							.num {
								border-radius: 6rpx;
								width: 34rpx;
								margin: 8rpx;
								height: 34rpx;
								border: 2rpx solid gainsboro;
								color: #BABABA;
								font-size: 24rpx;
								display: flex;
								align-items: center;
								justify-content: center;
							}
						}
					}
				}
			}
		}
	}
</style>